import numpy as np
import matplotlib.pyplot as plt

# import warnings
# warnings.filterwarnings('ignore')

from sklearn.datasets import load_breast_cancer
data = load_breast_cancer()
x = data.data
y = data.target

from sklearn.linear_model import LogisticRegression
#     C : float, optional (default=1.0)
#         Inverse of regularization strength; must be a positive float.
#         Like in support vector machines, smaller values specify stronger
#         regularization.
model = LogisticRegression(solver='liblinear',
                           max_iter=1000,
                           penalty='l2',
                           C=0.33)
model.fit(x, y)
print(f'Score: {model.score(x, y)}')

# confusion matrix
from sklearn.metrics import confusion_matrix
h = model.predict(x)
print(confusion_matrix(y, h))

# roc
from sklearn.metrics import roc_curve, roc_auc_score
proba = model.predict_proba(x)
print(f'roc auc sore = {roc_auc_score(y, proba[:, 1])}')
fpr, tpr, thre = roc_curve(y, proba[:, 1])
plt.plot(fpr, tpr)
for i, th in enumerate(thre):
    plt.annotate(f'{th:.2f}', xy=[fpr[i], tpr[i]])

# finally show all drawings
plt.show()
